﻿using System;
using System.Data.Common;
using System.Collections.Generic;

namespace EvidenceManagement.Data.Common
{
    public interface IDataObjectCommand
    {
        /// <summary>
        /// Inserts the specified data object to the data source.
        /// </summary>
        /// <typeparam name="T">The type of the data object to insert.</typeparam>
        /// <param name="dataObject">The data object to insert.</param>
        /// <returns></returns>
        bool Insert<T>(T dataObject);

        /// <summary>
        /// Inserts the specified data object to the data source.
        /// </summary>
        /// <typeparam name="T">The type of the data object to insert.</typeparam>
        /// <param name="dataObject">The data object to insert.</param>
        /// <param name="transaction">The database transaction to wrap the command with.</param>
        /// <returns></returns>
        bool Insert<T>(T dataObject, DbTransaction transaction);

        /// <summary>
        /// Reads the specified data object on the data source.
        /// </summary>
        /// <typeparam name="T">The type of the data object to read.</typeparam>
        /// <param name="dataObject">The data object to read into.</param>
        /// <returns></returns>
        bool Read<T>(T dataObject);

        /// <summary>
        /// Reads the specified data object on the data source.
        /// </summary>
        /// <typeparam name="T">The type of the data object to read.</typeparam>
        /// <param name="dataObject">The data object to read into.</param>
        /// <param name="transaction">The database transaction to wrap the command with.</param>
        /// <returns></returns>
        bool Read<T>(T dataObject, DbTransaction transaction);

        bool ReadRelation<T>(T dataObject);

        bool ReadRelation<T>(T dataObject, DbTransaction transaction);

        /// <summary>
        /// Returns a generic list of the specified data object type.
        /// </summary>
        /// <typeparam name="T">The type of the data object to read</typeparam>
        /// <param name="dataObject">The data object to list.</param>
        /// <returns></returns>
        IList<T> ReturnList<T>(T dataObject);

        /// <summary>
        /// Returns a generic list of the specified data object type.
        /// </summary>
        /// <typeparam name="T">The type of the data object to read</typeparam>
        /// <param name="dataObject">The data object to list.</param>
        /// <param name="transaction">The database transaction to wrap the command with.</param>
        /// <returns></returns>
        IList<T> ReturnList<T>(T dataObject, DbTransaction transaction);

        /// <summary>
        /// Returns a generic list of the specified data object type.
        /// </summary>
        /// <typeparam name="T">The type of the data object to read</typeparam>
        /// <param name="dataObject">The data object to list.</param>
        /// <param name="maxCount">The max number of data objects to return in the list.</param>
        /// <returns></returns>
        IList<T> ReturnList<T>(T dataObject, int maxCount);

        /// <summary>
        /// Returns a generic list of the specified data object type.
        /// </summary>
        /// <typeparam name="T">The type of the data object to read</typeparam>
        /// <param name="dataObject">The data object to list.</param>
        /// <param name="maxCount">The max number of data objects to return in the list.</param>
        /// <param name="transaction">The database transaction to wrap the command with.</param>
        /// <returns></returns>
        IList<T> ReturnList<T>(T dataObject, int maxCount, DbTransaction transaction);

        /// <summary>
        /// Updates the specified data object on the data source.
        /// </summary>
        /// <typeparam name="T">The type of the data object to update.</typeparam>
        /// <param name="dataObject">The data object to update.</param>
        /// <returns></returns>
        bool Update<T>(T dataObject);

        /// <summary>
        /// Updates the specified data object on the data source.
        /// </summary>
        /// <typeparam name="T">The type of the data object to update.</typeparam>
        /// <param name="dataObject">The data object to update.</param>
        /// <param name="transaction">The database transaction to wrap the command with.</param>
        /// <returns></returns>
        bool Update<T>(T dataObject, DbTransaction transaction);
        
        /// <summary>
        /// Deletes the specified data object on the data source.
        /// </summary>
        /// <typeparam name="T">The type of the data object to delete.</typeparam>
        /// <param name="dataObject">The data object to delete.</param>
        /// <returns></returns>
        bool Delete<T>(T dataObject);

        /// <summary>
        /// Deletes the specified data object on the data source.
        /// </summary>
        /// <typeparam name="T">The type of the data object to delete.</typeparam>
        /// <param name="dataObject">The data object to delete.</param>
        /// <param name="transaction">The database transaction to wrap the command with.</param>
        /// <returns></returns>
        bool Delete<T>(T dataObject, DbTransaction transaction);

    }
}
